﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace hcom
{
	public class hPage : System.Web.UI.Page
	{
		//===========================================================
		// 验证是否按F5刷新，防止重提交。
		// 实际测试，如果先提交一次，再提交第二个的过程中按F5键，会把第一次的内容提交上去
		// IE10.0.5 Chrome27 一样
		// 只能用于不太重要的场合，重要时还是要用跳转页面的方法。
		private bool _refreshState;
		private bool _isRefresh;

		public bool IsRefresh
		{
			get
			{
				return _isRefresh;
			}
		}

		protected override void LoadViewState(object savedState)
		{
			object[] allStates = (object[])savedState;
			base.LoadViewState(allStates[0]);
			_refreshState = (bool)allStates[1];
			_isRefresh = _refreshState == (bool)Session["__ISREFRESH"];
		}

		protected override object SaveViewState()
		{
			Session["__ISREFRESH"] = _refreshState;
			object[] allStates = new object[2];
			allStates[0] = base.SaveViewState();
			allStates[1] = !_refreshState;
			return allStates;
		}

	}
}